<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/5/21 0021
 * Time: 15:39
 */

namespace Api\Controller;


class BaseController
{
    public function __construct()
    {
        header('content-type:application/json;charset=utf8');
        /* 读取数据库中的配置 */
        $config =   S('DB_CONFIG_DATA');
        if(!$config){
            $config =   api('Config/lists');
            S('DB_CONFIG_DATA',$config);
        }
        C($config); //添加配置
    }

    protected function success($info, $data = [], $code = 1)
    {
        $result = ['code' => $code, 'info' => $info, 'data' => $data];
        exit(json_encode($result,JSON_UNESCAPED_UNICODE));
    }
    protected function error($info, $data = [], $code = 0)
    {
        $result = ['code' => $code, 'info' => $info, 'data' => $data];
        exit(json_encode($result,JSON_UNESCAPED_UNICODE));
    }
}